// pages/wait_appraise/wait_appraise.js
const app = getApp(), core = require('../../utils/core'), util = require('../../utils/util');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    core.get({url:'xilujob.interview_comment/not_comment_list',success:ret=>{
      this.setData({list: ret.data});
    }});
  },
  bindCreateComment(event) {
    let index = event.currentTarget.dataset.index;
    let interview = this.data.list[index];
    wx.navigateTo({
      url: '/pages/wait_evaluate/wait_evaluate',
      events: {
        dataTransfer: data => {
          let interview = data.interview;
          for(let i=0;i<this.data.list.length;i++) {
            if(this.data.list[i].id==interview.id) {
              this.data.list.splice(i,1);
              this.setData({list: this.data.list});
              break;
            }
          }
          app.eventBus.emit(app.Events.InterviewCommentAdd, {count: this.data.list.length});
        }
      },
      success: res => {
        res.eventChannel.emit('dataTransfer',{interview: interview});
      }
    });
  }

});
